this.view = new FolderView(this._folder, id, parentView);
- this._itemDragBeginId = Main.overview.connect(
- 'item-drag-begin', this._onDragBegin.bind(this));
- this._itemDragEndId = Main.overview.connect(
- 'item-drag-end', this._onDragEnd.bind(this));
+ this._iconIsHovering = false;
this.connect('destroy', this._onDestroy.bind(this));
}
_onDestroy() {
- Main.overview.disconnect(this._itemDragBeginId);
- Main.overview.disconnect(this._itemDragEndId);
-
if (this._dragMonitor) {
DND.removeDragMonitor(this._dragMonitor);
this._dragMonitor = null;
return this.view.getAllItems().map(item => item.id);
}
- _onDragBegin() {
- this._dragMonitor = {
- dragMotion: this._onDragMotion.bind(this),
- };
- DND.addDragMonitor(this._dragMonitor);
- }
+ _setHoveringByDnd(hovering) {
+ if (this._iconIsHovering == hovering)
+ return;
- _onDragMotion(dragEvent) {
- let target = dragEvent.targetActor;
+ this._iconIsHovering = hovering;
- if (!this.contains(target) || !this._canAccept(dragEvent.source))
- this.remove_style_pseudo_class('drop');
- else
+ if (hovering) {
+ this._dragMonitor = {
+ dragMotion: this._onDragMotion.bind(this),
+ };
+ DND.addDragMonitor(this._dragMonitor);
this.add_style_pseudo_class('drop');
-
- return DND.DragMotionResult.CONTINUE;
+ } else {
+ DND.removeDragMonitor(this._dragMonitor);
+ this.remove_style_pseudo_class('drop');
+ }
}
- _onDragEnd() {
- this.remove_style_pseudo_class('drop');
- DND.removeDragMonitor(this._dragMonitor);
+ _onDragMotion(dragEvent) {
+ if (!this.contains(dragEvent.targetActor) ||
+ !this._canAccept(dragEvent.source))
+ this._setHoveringByDnd(false);
+
+ return DND.DragMotionResult.CONTINUE;
}
_canAccept(source) {
if (!this._canAccept(source))
return DND.DragMotionResult.NO_DROP;
+ this._setHoveringByDnd(true);
+
return DND.DragMotionResult.MOVE_DROP;
}
acceptDrop(source) {
+ this._setHoveringByDnd(false);
+
if (!this._canAccept(source))
return false;
this._delegate = this;
- this._hasDndHover = false;
this._folderPreviewId = 0;
// Get the isDraggable property without passing it on to the BaseIcon:
});
}
- this._dragMonitor = null;
- this._itemDragBeginId = Main.overview.connect(
- 'item-drag-begin', this._onDragBegin.bind(this));
- this._itemDragEndId = Main.overview.connect(
- 'item-drag-end', this._onDragEnd.bind(this));
+ this._otherIconIsHovering = false;
this._menuTimeoutId = 0;
this._stateChangedId = this.app.connect('notify::state', () => {
}
_onDestroy() {
- Main.overview.disconnect(this._itemDragBeginId);
- Main.overview.disconnect(this._itemDragEndId);
-
if (this._folderPreviewId > 0) {
GLib.source_remove(this._folderPreviewId);
this._folderPreviewId = 0;
}
_setHoveringByDnd(hovering) {
+ if (this._otherIconIsHovering == hovering)
+ return;
+
+ this._otherIconIsHovering = hovering;
+
if (hovering) {
+ this._dragMonitor = {
+ dragMotion: this._onDragMotion.bind(this),
+ };
+ DND.addDragMonitor(this._dragMonitor);
+
if (this._folderPreviewId > 0)
return;
return GLib.SOURCE_REMOVE;
});
} else {
+ DND.removeDragMonitor(this._dragMonitor);
+
if (this._folderPreviewId > 0) {
GLib.source_remove(this._folderPreviewId);
this._folderPreviewId = 0;
}
}
- _onDragBegin() {
- this._dragMonitor = {
- dragMotion: this._onDragMotion.bind(this),
- };
- DND.addDragMonitor(this._dragMonitor);
- }
-
_onDragMotion(dragEvent) {
- let target = dragEvent.targetActor;
- let isHovering = target == this || this.contains(target);
- let canDrop = this._canAccept(dragEvent.source);
- let hasDndHover = isHovering && canDrop;
-
- if (this._hasDndHover != hasDndHover) {
- this._setHoveringByDnd(hasDndHover);
- this._hasDndHover = hasDndHover;
- }
+ if (!this.contains(dragEvent.targetActor))
+ this._setHoveringByDnd(false);
return DND.DragMotionResult.CONTINUE;
}
- _onDragEnd() {
- this.remove_style_pseudo_class('drop');
- DND.removeDragMonitor(this._dragMonitor);
- }
-
handleDragOver(source) {
if (source == this)
return DND.DragMotionResult.NO_DROP;
if (!this._canAccept(source))
return DND.DragMotionResult.CONTINUE;
+ this._setHoveringByDnd(true);
+
return DND.DragMotionResult.MOVE_DROP;
}